package com.tcxhb.job.dao.dataobject;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tcxhb.job.common.model.job.JobParams;
import com.tcxhb.job.common.model.job.RunStrategy;
import com.tcxhb.job.common.model.job.ScheduleConf;
import com.tcxhb.job.dao.handler.biz.JobParamsHandler;
import com.tcxhb.job.dao.handler.biz.RunStrategyHandler;
import com.tcxhb.job.dao.handler.biz.ScheduleConfHandler;
import lombok.Data;

/**
 * author:auto.generator
 * time: 2023-11-02
 */

@TableName(value = "tc_job_info", autoResultMap = true)
@Data
public class JobInfoDO extends BaseDO {
    /**
     * *所属应用ID
     **/
    private String appName;

    /**
     * *任务名称
     **/
    private String jobName;

    /**
     * *调度类型：0,手动触发，1定时触发
     **/
    private Integer scheduleType;

    /**
     * *调度配置，值含义取决于调度类型
     **/
    @TableField(typeHandler = ScheduleConfHandler.class)
    private ScheduleConf scheduleConf;

    /**
     * *执行器任务handler，参数
     **/
    @TableField(typeHandler = JobParamsHandler.class)
    private JobParams jobParams;

    /**
     * *运行参数配置: 重试次数，超时时间
     **/
    @TableField(typeHandler = RunStrategyHandler.class)
    private RunStrategy runStrategy;

    /**
     * *调度状态：0-停止，1-运行
     **/
    private Integer status;

    /**
     * *上次调度时间
     **/
    private Long lastTime;

    /**
     * *下次调度时间
     **/
    private Long nextTime;

    /**
     * *创建者
     **/
    private String creator;

    public String uniqId(){
        StringBuilder builder= new StringBuilder();
        builder.append(this.getId()).append("-").append(this.getNextTime());
        return builder.toString();
    }
}
